Skip to content

Add support for multiple cameras in multiple robots - #82

Open
pvela2017 wants to merge 1 commit into
orbbec:mainfrom
pvela2017:Add_namespace_and_prefix
Open

Add support for multiple cameras in multiple robots#82
pvela2017 wants to merge 1 commit into
orbbec:mainfrom
pvela2017:Add_namespace_and_prefix

Conversation

@pvela2017

Copy link
Copy Markdown

Hello,

I realized that when using multiple robots with multiple cameras it wasn't possible to set a prefix. So I modified the the launch files and main code to support a prefix (example: robot1, robot2), maintaining backward compatibility if no prefix is set.

I tested the modifications using 2 femto bolts:

Test with prefix:
frames_with_prefix
topics_with_prefix_removed

Test without prefix:
frames_without_prefix
topics_without_prefix

@obshenlanzhou

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

PushRosNamespace(LaunchConfiguration('camera_name')),

P2 Badge Remove the duplicate camera namespace push

The generic launch file still pushes camera_name even though the component now also sets namespace=LaunchConfiguration('camera_name'). Launching ob_camera.launch.py with the defaults therefore nests the camera namespace (publishing under /camera/camera/... instead of the previous /camera/...), unlike the model-specific launch files in this change that push prefix here; this breaks existing subscribers and tools using the documented /camera/... topics.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +33 to +35
node_, "~/color/image_raw", rgb_qos);
depth_sub_ = std::make_shared<message_filters::Subscriber<sensor_msgs::msg::Image>>(
node_, "depth/image_raw", depth_qos);
node_, "~/depth/image_raw", depth_qos);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep D2C subscriptions on the image topics

When enable_d2c_viewer is true, these subscriptions now use private node-relative names (~), which expand below the node name, while setupPublishers() still publishes the camera images on the relative topics color/image_raw and depth/image_raw under the node namespace. As a result the synchronizer never receives the camera frames and the D2C viewer output stays silent unless separate private-topic publishers are added.

Useful? React with 👍 / 👎.

depth_to_other_extrinsics_publishers_[COLOR] =
node_->create_publisher<orbbec_camera_msgs::msg::Extrinsics>(
"/" + camera_name_ + "/depth_to_color", extrinsics_qos);
"/" + prefix_ + camera_name_ + "/depth_to_color", extrinsics_qos);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve namespace separators for extrinsics topics

With the new prefix launch argument used as a ROS namespace segment, a normal multi-robot launch such as prefix:=robot1 camera_name:=camera should publish under /robot1/camera/..., but this absolute topic concatenates the two strings into /robot1camera/depth_to_color. The same pattern is used for the other extrinsics publishers in this block, so prefixed deployments publish latched extrinsics outside the robot namespace and consumers looking under /robot1/camera miss them.

Useful? React with 👍 / 👎.

if (enable_stream_[DEPTH] && enable_stream_[COLOR]) {
static const char *frame_id = "depth_to_color_extrinsics";
std::string string_frame_id = prefix_ + camera_name_ + "_" + "depth_to_color_extrinsics";
static const char *frame_id = string_frame_id.c_str();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Do not cache frame ids from a local string

When more than one OBCameraNode is loaded in the same component process, this static pointer is initialized only once from the first call's stack-local string_frame_id; after that call returns the pointer dangles, and later cameras reuse stale or corrupted extrinsics frame IDs instead of their own prefix/camera_name. Store the frame id as a normal std::string (or a static string value if it truly must be static) before passing it to obExtrinsicsToMsg.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants